// Criterion requires the second argument to be by reference
#![allow(clippy::trivially_copy_pass_by_ref)]

use criterion::{black_box, Bencher};
use secp256k1_native::{verify, Message, PublicKey, Signature};

pub fn secp256k1_native_verify(bench: &mut Bencher, _i: &()) {
    let public_key = PublicKey::parse_compressed(&[
        0x02, 0xc6, 0x6e, 0x7d, 0x89, 0x66, 0xb5, 0xc5, 0x55, 0xaf, 0x58, 0x05, 0x98, 0x9d, 0xa9,
        0xfb, 0xf8, 0xdb, 0x95, 0xe1, 0x56, 0x31, 0xce, 0x35, 0x8c, 0x3a, 0x17, 0x10, 0xc9, 0x62,
        0x67, 0x90, 0x63,
    ])
    .expect("public keys must be 33 or 65 bytes, serialized according to SEC 2");

    let message = Message::parse(&[
        0xaa, 0xdf, 0x7d, 0xe7, 0x82, 0x03, 0x4f, 0xbe, 0x3d, 0x3d, 0xb2, 0xcb, 0x13, 0xc0, 0xcd,
        0x91, 0xbf, 0x41, 0xcb, 0x08, 0xfa, 0xc7, 0xbd, 0x61, 0xd5, 0x44, 0x53, 0xcf, 0x6e, 0x82,
        0xb4, 0x50,
    ]);

    let sig = Signature::parse(&[
        0xdc, 0x4d, 0xc2, 0x64, 0xa9, 0xfe, 0xf1, 0x7a, 0x3f, 0x25, 0x34, 0x49, 0xcf, 0x8c, 0x39,
        0x7a, 0xb6, 0xf1, 0x6f, 0xb3, 0xd6, 0x3d, 0x86, 0x94, 0x0b, 0x55, 0x86, 0x82, 0x3d, 0xfd,
        0x02, 0xae, 0x3b, 0x46, 0x1b, 0xb4, 0x33, 0x6b, 0x5e, 0xcb, 0xae, 0xfd, 0x66, 0x27, 0xaa,
        0x92, 0x2e, 0xfc, 0x04, 0x8f, 0xec, 0x0c, 0x88, 0x1c, 0x10, 0xc4, 0xc9, 0x42, 0x8f, 0xca,
        0x69, 0xc1, 0x32, 0xa2,
    ]);

    bench.iter(|| {
        black_box(verify(
            black_box(&message),
            black_box(&sig),
            black_box(&public_key),
        ))
    })
}
